import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;

public class ClientTxt {
    public static void main(String[] args) {
        Socket socket = null;
        OutputStream outputStream = null;
        InputStream inputStream = null;

        try {
            socket = new Socket(InetAddress.getByName("127.0.0.1"), 9999);
            outputStream = socket.getOutputStream();
            outputStream.write("qwertyuiop".getBytes());
            socket.shutdownOutput();

            inputStream = socket.getInputStream();
            byte[] b = new byte[1024];
            int length = inputStream.read(b);
            while (length != -1) {
                String str = new String(b);
                System.out.println(str);
                break;
            }
            socket.shutdownInput();

            outputStream.close();
            inputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
